﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Maticsoft.DBUtility;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// 数据转换临时用 数据类
    /// </summary>
    public class TmpDataConvert
    {
        public TmpDataConvert()
        {
        }
        /// <summary>
        /// 更新图片新闻缩率图
        /// </summary>
        public void UpdateDocumentThumb(List<Model.Document> documentModelList)
        {
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo cmds = new CommandInfo();
            StringBuilder strSql = new StringBuilder();

            foreach (Model.Document documentModel in documentModelList)
            {
                strSql = new StringBuilder();
                cmds = new CommandInfo();

                //修改信息
                strSql.Append("update t_document set ");
                strSql.Append("FThumbGenType=@FThumbGenType,");
                strSql.Append("FThumbContent=@FThumbContent,");
                strSql.Append("FThumbFileExt=@FThumbFileExt,");
                strSql.Append("FThumbSrvFileName=@FThumbSrvFileName,");
                strSql.Append("FThumbOldFileName=@FThumbOldFileName,");
                strSql.Append("FThumbSeqID=@FThumbSeqID");
                strSql.Append(" where FDocId=@FDocId ");
                SqlParameter[] parameters = {
					new SqlParameter("@FDocId", SqlDbType.Decimal,9),
					new SqlParameter("@FThumbGenType", SqlDbType.Char,1),
					new SqlParameter("@FThumbContent", SqlDbType.Image),
					new SqlParameter("@FThumbFileExt", SqlDbType.VarChar,80),
					new SqlParameter("@FThumbSrvFileName", SqlDbType.VarChar,255),
					new SqlParameter("@FThumbOldFileName", SqlDbType.VarChar,255),
					new SqlParameter("@FThumbSeqID", SqlDbType.Int,4)
                   };
                parameters[0].Value = documentModel.FDocId;
                parameters[1].Value = documentModel.FThumbGenType;
                parameters[2].Value = documentModel.FThumbContent;
                parameters[3].Value = documentModel.FThumbFileExt;
                parameters[4].Value = documentModel.FThumbSrvFileName;
                parameters[5].Value = documentModel.FThumbOldFileName;
                parameters[6].Value = documentModel.FThumbSeqID;

                cmds.CommandText = strSql.ToString();
                cmds.Parameters = parameters;
                cmdList.Add(cmds);
            }
            if (cmdList.Count > 0)
            {
                DbHelperSQL.ExecuteSqlTranWithIndentity(cmdList, 30 * 60);
            }
        }
    }
}
